<?php

namespace app\admin\controller;
//Cache::clear();
// use think\Login;
// use My\Redis;
use think\Db;
use think\Session;
use think\Cookie;

class Index extends Login
{
    public function index()
    {
        $queslikes = Db::name('question')->order(['likes'=>'desc'])->limit(15)->select();
        $catelist = Db::name('question')->field('count(id) count,cid')->group('cid')->select();
        $catename = Db::name('category')->field('name')->select();
        //把category的name放入$catelist
        for ($i=0;$i<14;$i++){
            $catelist[$i]['name'] = $catename[$i]['name'];
        }
        return view('index/index',['CSS_PATH'=>config('admin_css'),
                                    'JS_PATH'=>config('admin_js'),
                                    'ICON_PATH'=>config('admin_icon'),
                                    'IMG_PATH'=>config('admin_img'),
                                    'admin_name'=>Session::get('admin_name'),
                                    'admin_id'=>Session::get('admin_id'),
                                    'queslikes'=>$queslikes,
                                    'catelist'=>$catelist
        ]);
    }

}
